<?php 

/* ------------------------------------------------------------
 * Page:Seach Result
 * Author: Gustavo Lozano & Fredrik Kronander
 * Description: Show a table with the result of the search
 * 
 **------------------------------------------------------------*/

?>

<form method="get" action="index.php">
<table width="60%" align="center">
	
<?php 
	require_once '../source/UtsAirs.php';	
	require_once '../source/Flight.php';
	
	$utsAirs = new UtsAirs();
	$flightsSearched = $utsAirs -> searchFlights($_REQUEST['fromCity'], $_REQUEST['toCity']);
	
	if(count($flightsSearched) > 0 )
	{
?>
	<tr>
	
		<td>From</td>
		<td>To</td>
		<td>Select</td>
	</tr>
	
<?php 	
		foreach($flightsSearched as $flight)
		{
?>	
		<tr>
		
<?php 
			echo "<td>".$flight->fromCity."</td>";
			echo "<td>".$flight->toCity."</td>";
			
			echo "<td><input type=\"radio\" name=\"flightNo\" id=\"flightNo\" value=\"".$flight->id."\"/></td>";
?>
		</tr>
<?php 
		}
?>
</table>	
		<input type="submit" id= "book" value="Make Booking For Selected Flights >"/>
		<input type="hidden" name="content" value="Selected_Flights" />
		
<?php 
	}
	else 
		echo "Flights Not Found"		
?>
</form>
	